package com.sjhang.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sjhang.entity.TbTeach;
import com.sjhang.mapper.TbTeachMapper;
import com.sjhang.service.TbTeachService;
import com.sjhang.utils.ListParamVo;
import com.sjhang.utils.ResultResponse;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 教材表
 服务实现类
 *
 */
@Service
public class TbTeachServiceImpl extends ServiceImpl<TbTeachMapper, TbTeach> implements TbTeachService {

    @Resource
    private TbTeachMapper tbTeachMapper;

    /***
     * @description 查询大纲对应的教材
     */
    @Override
    public ResultResponse selectTeach(ListParamVo listParamVo) {
        IPage<TbTeach> list = tbTeachMapper.selectTeachPage(
                new Page<TbTeach>(listParamVo.getCurrent(),listParamVo.getSize()),
                 listParamVo.getParamMap().get("outlienID")
        );
        return ResultResponse.SUCCESS(list);
    }

    /***
     * @description 新增对应教材
     * @params [listParamVo]
     */
    @Override
    public ResultResponse insertTeach(TbTeach tbTeach) {
        tbTeachMapper.insert(tbTeach);
        return ResultResponse.SUCCESS();
    }

    /***
     * @description 修改对应教材
     * @params [listParamVo]
     */
    @Override
    public ResultResponse updateTeach(TbTeach tbTeach) {
        tbTeachMapper.updateById(tbTeach);
        return ResultResponse.SUCCESS();
    }

    /***
     * @description 删除对应教材
     * @params [listParamVo]
     */
    @Override
    public ResultResponse deleteTeach(Long listParamVo) {
        tbTeachMapper.deleteById(listParamVo);
        return ResultResponse.SUCCESS();
    }
}
